let {Texas} = require('Poker')

cc.Class({
    extends: cc.Component,
    properties: {
        header: cc.Sprite,
        cardType: cc.Label,
        money: cc.Label,
        username: cc.Label,
        placehold: cc.SpriteFrame,
        info: {
            set(value) {
                let {money, name, avatar, k} = value
                this.money.string = (money > 0 ? '+' : '') + money
                let tempName = name
                if (name.length > 4) {
                    tempName = tempName.substring(0, 4)
                    tempName += '..'
                }
                this.username.string = tempName

                if (avatar) {
                    let image = new Image()
                    //image.crossOrigin = "Anonymous"
                    image.onload = () => {
                        var texture2d = new cc.Texture2D();
                        texture2d.initWithElement(image)
                        texture2d.handleLoadedTexture(false)

                        let s = new cc.SpriteFrame(texture2d)
                        this.header.spriteFrame = s
                    }
                    image.src = avatar
                } else {
                    this.header.spriteFrame = this.placehold
                }
            }
        }
    },

    onLoad() {

    },
})